
<fieldset>
    <legend><?php echo $data['Task']['taskcode'];?>
    <?php if(isset($sc) && !empty($sc) && isset($sc) && !empty($host)){?>
    	<a title="push" href="javascript:;" onclick="ajax('deployContent','deploys/index/<?php echo $data['Task']['id'];?>');"> <img border="0" src="<?php echo $this->webroot; ?>img/backend/icon-16-upload.png"/></a>
    <?php }?>
    
    <span id="watch">
    	<?php if(!$watchStatus){?>
    		<a title="watch" href="javascript:;" onclick="deactivateEditors();ajax('watch','<?php echo $this->params['controller']?>/watch/<?php echo $data['Task']['id'];?>');"> <img border="0" src="<?php echo $this->webroot; ?>img/backend/icon-16-eye.png"/></a>
    	<?php }else{?>
    		<a title="unwatch" href="javascript:;" onclick="deactivateEditors();ajax('watch','<?php echo $this->params['controller']?>/unwatch/<?php echo $data['Task']['id'];?>');"> <img border="0" src="<?php echo $this->webroot; ?>img/backend/icon-16-eyedel.png"/></a>
    	<?php }?>
    </span>
    <?php if(Configure::read('Session.isAdmin') || Configure::read('Session.isSa') || Configure::read('Session.isManager') || Configure::read('Session.isOwner')){?> <span title="<?php _resource('edit');?>"><a href="javascript:;" onclick="deactivateEditors();ajax('addContent','<?php echo $this->params['controller']?>/edit/<?php echo $data['Task']['id'];?>');"> <img border="0" src="<?php echo $this->webroot; ?>img/backend/icon-16-edit.png"/></a></span><?php }?>
    </legend>
<form id="adminForm2" name="adminForm2" method="post"
		action="<?php echo $this->params['controller'].'/changeStatus/'.$data['Task']['id'] ?>">
<table border="0" class="form" style="width: 100%;margin-top:0;">
			<tr>
				<td class="label" align="right" width="100px"><?php _resource('task') ?>

				</td>
				<td class="data"  align="left"><?php echo $data['Task']['taskcode'].' '.$data['Task']['name'];?>
				</td>
			</tr>
			
			<?php if(isset($data['FileAttach'])&& !empty($data['FileAttach'])){ ?>
		<tr>          
       		<td class="label" align="right" width="100px"><?php _resource('file attach') ?>
       		
       		</td>
       		<td class="data"  align="left">
       		<div id="divUploadContainer2" style="text-align: left">
       		<?php 
       			foreach($data['FileAttach'] as $k=>$v){
       			?>
       			<div class="progressWrapper" id="fileUpload<?php echo $v['FileAttach']['id']?>" style="opacity: 1;">
       				<div class="fileContainer">
       					<a href="<?php echo SITE_URL.'/uploaded/Task/document/'.$v['FileManager']['name']?>"><?php echo $v['FileManager']['name']?></a>
       					<?php if(isset($v['User']['username']) && !empty($v['User']['username']) && $v['User']['username']!=$user['username']){?>
       						<span style="color:#999">(<?php echo $v['User']['username']?>)</span> 
       					<?php }
       						if($v['User']['username']==$user['username'] || Configure::read('Session.isAdmin') || Configure::read('Session.isSa') || Configure::read('Session.isManager') || Configure::read('Session.isOwner')){
       					?>
       					
       					<span title="delete"><a href="javascript:;" onclick="removeFile2('<?php echo $v['FileAttach']['id']?>')"> <img border="0" src="<?php echo SITE_URL?>/img/backend/publish_x.png"></a></span>
       					<?php }?>
       				</div>
       			</div>
       		<?php }?>
       		</div>       		      
        	</td>
        </tr>
        <?php }?>

		<?php if(!empty($data['Task']['description'])){?>
			<tr>
				<td class="label" align="right" width="100px"><?php _resource('description') ?>

				</td>
				<td class="data" align="left"><?php echo $data['Task']['description'];?>
				</td>
			</tr>
			<?php }?>
			<?php if(!empty($data['Priority']['name'])){?>
			<tr>
				<td class="label" align="right" width="100px"><?php _resource('prior') ?>
				</td>
				<td class="data" align="left"><?php 
				if(!empty($data['Priority']['image']))
					echo '<img src="'.$this->webroot.'uploaded/Priority/image/'.$data['Priority']['image'].'" /> &nbsp;';
				echo $data['Priority']['name'];
				?></td>
			</tr>
			<?php }?>
			<?php if(!empty($data['Type']['name'])){?>
			<tr>
				<td class="label" align="right" width="100px"><?php _resource('type') ?>
				</td>
				<td class="data" align="left"><?php
				if(!empty($data['Type']['image']))
					echo '<img src="'.$this->webroot.'uploaded/Type/image/'.$data['Type']['image'].'" /> &nbsp;';
				 echo $data['Type']['name'];
				 
				 ?></td>
			</tr>
			<?php }?>
			<?php if(!empty($data['Status']['name'])){?>
			<tr>
				<td class="label" align="right" width="100px"><?php _resource('status') ?>

				</td>
				<td class="data" align="left"><?php 
				if(!empty($data['Status']['image']))
					echo '<img src="'.$this->webroot.'uploaded/Status/image/'.$data['Status']['image'].'" /> &nbsp;';
				if(Configure::read('Session.isAdmin') || Configure::read('Session.isSa') || Configure::read('Session.isManager') || Configure::read('Session.isOwner')){
					echo $this->Form->input($uses[0].'.status_id', array('type'=>'select','options'=>$statuses,'default'=>$data['Task']['status_id'],'empty'=>false,"class"=>"inputbox","label"=>"","div"=>"","error"=>""));
					echo $this->Form->hidden($uses[0].'.oldstatus_id',array('value'=>$data['Status']['id']));
				}
				else echo $data['Status']['name'];
				?></td>
			</tr>
			<?php }?>
			
			<?php 
			if(Configure::read('Session.isAdmin') || Configure::read('Session.isSa') || Configure::read('Session.isManager') || Configure::read('Session.isAssignee') || Configure::read('Session.isOwner')){
			if(isset($users)>0 ){?>
		 	<tr>          
	       		<td class="label" align="right" width="100px"><?php _resource('Assign to:') ?>
	       		
	       		</td>
	       		<td class="data"  align="left">
	       			<?php 
	        foreach($users as $k=>$v){
	        	$check='';
	        	if($data['Task']['assignees']==$v['User']['id'])$check='checked="checked"';
				echo '<input '.$check.' type="radio" value="'.$v['User']['id'].'" id="'.$uses[0].$v['User']['id'].'" name="data['.$uses[0].'][assignees]" />
				<label for="'.$uses[0].$v['User']['id'].'">'.$v['User']['username'].'</label><br />';
			 }
	       			?>
	       		</td>           
	        </tr>   
	        <?php } }
	        else{
	        ?>
	        <tr>          
	       		<td class="label" align="right" width="100px"><?php _resource('Assignee') ?>
	       		
	       		</td>
	       		<td class="data"  align="left">
	       			<?php echo $data['Assignee']['username'];?>
	       		</td>           
	        </tr>   
	        
	        <?php }?>

			<?php if(isset($fields) && count($fields)>0){
				foreach($fields as $k=>$v){
					
					?>

			<tr>
				<td class="label" align="right" width="100px"><?php _resource($v['Field']['name']) ?>

				</td>
				<td class="data"  align="left"><?php 
				if(Configure::read('Session.isAdmin') || Configure::read('Session.isSa') || Configure::read('Session.isManager') || Configure::read('Session.isAssignee') || Configure::read('Session.isOwner')){
					echo $this->Form->input('Field.'.$v['Field']['name'].'.value',array('value'=>$v['Field']['value'],'class'=>'input','label'=>'','size'=>60,'maxlength'=>255));					
					echo $this->Form->hidden('Field.'.$v['Field']['name'].'.fieldvalue_id',array('value'=>$v['FieldValue']['id']));
					echo $this->Form->hidden('Field.'.$v['Field']['name'].'.field_id',array('value'=>$v['Field']['id']));
					echo $this->Form->hidden('Field.'.$v['Field']['name'].'.oldvalue',array('value'=>$v['Field']['value']));
				}
				else echo $v['Field']['value']
				?></td>
			</tr>
			<?php }}?>


		</table>
		
		<?php if(Configure::read('Session.isAdmin') || Configure::read('Session.isSa') || Configure::read('Session.isManager') || Configure::read('Session.isAssignee') || Configure::read('Session.isOwner')){?>
		<center>
		<div style="width: 130px;">
			<div class="button" style="float: right"><a onclick="closeBox('addContent','mainContent')" href="javascript:;" title="<?php echo _resource('close') ?>"  > <span class="icon-32-cancel"> </span></a> </div>
			<div class="button" style="float: right">
				<a onclick="adminForm.reset();" href="javascript:;"
					title="<?php echo _resource('reset') ?>"> <span class="icon-32-back"> </span>
				</a>
			</div>
			<div class="button" style="float: right">
				<a onclick="onFormSubmit2();" href="javascript:;"
					title="<?php echo _resource('save') ?>"> <span class="icon-32-save"> </span>
				</a>
			</div>
		</div>
		</center>
		<?php }?>
		</form>
	
</fieldset>

<div id="deployContent"></div>
<fieldset>
	<legend>
	<?php echo _resource('Comments')?>
	</legend>


<div id="commentContent"></div>

	<form id="adminForm" name="adminForm" method="post"
		action="<?php echo 'comments/add/'.$data[$uses[0]]['id'] ?>">
		
		<table border="0" class="form" style="width: 100%">	
			
			<tr>
				<td class="label" align="right" width="100px"><?php echo _resource('comment') ?>

				</td>
				<td align="left"><?php 
					
				echo $this->Form->textarea('Comment.comment',array('class'=>'','label'=>'','error'=>'','cols'=>100,'rows'=>10));


				?></td>
			</tr>
			
			
			 <tr>          
       		<td class="label" align="right" width="100px"><?php _resource('file attach') ?>
       		
       		</td>
       		<td align="left">
       		<div id="divUploadContainer" style="text-align: left">
       		
       		</div>
       		<div style="width: 80px; height: 18px; border: solid 1px #7FAAFF; background-color: #C5D9FF; padding: 2px;">
					<span id="spanButtonPlaceholder"></span>
				</div>     
				<div class="fieldset flash" id="divFileProgressContainer"></div>      
        	</td>
        </tr>

		</table>
		
		
		
		<center>
		<div style="width: 130px;">
			<div class="button" style="float: right"><a onclick="closeBox('addContent','mainContent')" href="javascript:;" title="<?php echo _resource('close') ?>"  > <span class="icon-32-cancel"> </span></a> </div>
			<div class="button" style="float: right">
				<a onclick="adminForm.reset();" href="javascript:;"
					title="<?php echo _resource('reset') ?>"> <span class="icon-32-back"> </span>
				</a>
			</div>
			<div class="button" style="float: right">
				<a onclick="onFormSubmit();" href="javascript:;"
					title="<?php echo _resource('save') ?>"> <span class="icon-32-save"> </span>
				</a>
			</div>
		</div>
		</center>
	</form>
</fieldset>

<script>
//refresh list
<?php if($this->Session->read('CurrentModule')=='Home')	echo 'ajax("listContent","homes/lists");';
	elseif($this->Session->read('CurrentModule')=='Task') echo 'ajax("listContent","tasks/lists");';
	?>

ajax('commentContent','comments/lists/<?php echo $data[$uses[0]]['id']?>');
activateEditor("CommentComment",{toolbar:'Basic'});
function onFormSubmit(){
	var content = ckeditor.getData();
	deactivateEditors();
	$('#adminForm').attr('action','<?php echo 'comments/add/'.$data[$uses[0]]['id'] ?>');
	$('#CommentComment').html(content);		
	submitForm('adminForm','commentContent');
}
function onFormSubmit2(){	
	deactivateEditors();
	submitForm('adminForm2','listContent');
	closeBox('addContent','mainContent');
}
function removeFile2(id){
	var answer=confirm("Are you sure?")
	if(answer)
	{
		removeFile('fileUpload'+id);
		ajax("commentContent","tasks/removefileattach/"+id);	
		
	}
}
function removeFile(id){
	$('#'+id).remove();
}
swfu = new SWFUpload({	      
	// Backend Settings
	upload_url: "<?php echo BACKEND_URL.'fileuploads/imageupload/document/'.$uses[0]?>",
	post_params: {"PHPSESSID": "<?php echo session_id(); ?>"},

	// File Upload Settings
	/*
		file_size_limit: "100 KB" // kilobytes
		file_size_limit: "10000 b" // bytes
		file_size_limit: "25mb" // megabytes
		file_size_limit: "2 gb" // gigabytes
		file_size_limit: "342222" // kilobytes
	*/
	file_size_limit : "5 MB",
	file_types : "*.*",
	file_types_description : "All",
	file_upload_limit : 0,

	// Event Handler Settings - these functions as defined in Handlers.js
	//  The handlers are not part of SWFUpload but are part of my website and control how
	//  my website reacts to the SWFUpload events.
	swfupload_preload_handler : preLoad,
	swfupload_load_failed_handler : loadFailed,
	file_queue_error_handler : fileQueueError,
	file_dialog_complete_handler : fileDialogComplete,
	upload_progress_handler : uploadProgress,
	upload_error_handler : uploadError,
	upload_success_handler : uploadSuccess,
	upload_complete_handler : uploadComplete,

	// Button Settings
	//button_image_url : "<?php echo $this->webroot?>plugins/SWFUpload/images/SmallSpyGlassWithTransperancy_17x18.png",
	button_placeholder_id : "spanButtonPlaceholder",
	button_width: 107,
	button_height: 38,
	button_text : 'Browse',
	button_text_style : '.button { font-family: Helvetica, Arial, sans-serif; font-size: 12pt; } .buttonSmall { font-size: 10pt; }',
	button_text_top_padding: 0,
	button_text_left_padding: 18,
	button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
	button_cursor: SWFUpload.CURSOR.HAND,
	
	// Flash Settings
	flash_url : "<?php echo $this->webroot?>plugins/SWFUpload/js/swfupload.swf",
			flash9_url : "<?php echo $this->webroot?>plugins/SWFUpload/js/swfupload_fp9.swf",
    
	custom_settings : {					
		//upload_target : "divFileProgressContainer",//upload status
		type:3,//1: image, 2: gallery , 3: multi file
		uploadContainer:"divUploadContainer",// contain upload , use for multi upload				
		fieldName: "<?php echo 'data[FileAttach]'?>",
		numOfMaxUpload:0  //max of upload file, 1 for single, >1 for multi, 0 for unlimit
	},
	
	// Debug Settings
    debug: false

});
scrollTopTo('addContent');
</script>


